package com.hyb.algorithm.data.struct.thread;

import java.util.concurrent.CompletableFuture;

/**
 * 面试官：用过CompletableFuture吗？
 * https://mp.weixin.qq.com/s/LZoCHnlYGa3sQgfnIpyAXQ
 *
 * @author: ybhu
 * @create: 2024/01/31 14:57
 */
public class CompletableFuture3Demo {

    public static void main(String[] args) {

        CompletableFuture<String> future1= CompletableFuture.supplyAsync(()->"朋友系小王去你家送药");
        CompletableFuture<String> future2=CompletableFuture.supplyAsync(()->"朋友小张去你家送药");

        CompletableFuture<Object> anyFutures=CompletableFuture.anyOf(future1,future2);

        System.out.println(anyFutures.join());
    }

}
